<?php

class CpnewsletterController extends Core_Controller_Action 
{
	private $_newsletter;
	private $_newsletterqueue;
	
	public function init() {
		$this->_newsletter = new Newsletter();
		$this->_newsletterqueue = new NewsletterQueue();
	}
	
	public function indexAction()
	{
		if($this->_request->isPost())
		{
			$post = $this->_request->getPost();
			$this->_newsletterqueue->body_pl = $post['body_pl'];
			$this->_newsletterqueue->body_en = $post['body_en'];
			$this->_newsletterqueue->body_cs = $post['body_cs'];
			$this->_newsletterqueue->type = $post['type'];
			$this->_newsletterqueue->rank = $post['rank'];
			$this->_newsletterqueue->last_u_id = 0;
			$this->_newsletterqueue->sent = "no";
			$this->_newsletterqueue->save();
		}
		$ob  = $this->_newsletterqueue->getItemBySent('no');
		$this->view->send = (get_class($ob)) ? false : true; 	
	}
}